// React 动态链接库
const webpack = require('webpack');
const path = require('path');
const mode = process.env.NODE_ENV;

module.exports = {
    entry: {
        react: ['react-hot-loader/patch', 'react', 'react-dom']
    },
    mode: mode ? mode : 'development',
    output: {
        path: path.join(__dirname, '../dist'),
        filename: '[name]-[chunkhash:7].dll.js',
        library: '__dll__[name]'
    },
    plugins: [
        new webpack.DllPlugin({
            // name 属性值规定与 library 属性值相同
            name: '__dll__[name]',
            // path 表示产生一个清单，这个清单可以找到打包的文件
            path: path.resolve(__dirname, '../dist', 'manifest.json'),
        }),
    ]
};